feat: session archive, sub-agent inspection UI, and live sub-agent streaming#4
Draft
feat: session archive, sub-agent inspection UI, and live sub-agent streaming#4
Conversation
…reaming Add SQLite-backed session archiving so terminated sandboxes retain conversation history, plus a sub-agent transparency UI that lets users inspect and live-stream child agent sessions nested in the parent chat. Session Archive: - Adapt OpenCodeDBReader from SDK to read OpenCode v1.2.0 SQLite schema - Add 4 PostgreSQL archive tables with indexes (Drizzle migrations) - Archive pipeline downloads SQLite from sandbox before destruction - Soft-delete sessions to preserve archive access - GET /api/sessions/:id/archive serves archived data in frontend format - ArchivedBanner component with stats and Fork button - ChatPage detects archived state, loads read-only view Sub-Agent Inspection: - 3 new API endpoints for archived + live child session data - useChildSessions hook with caching (archived + live modes) - ChildSessionView expandable panel for nested conversations - ToolCallCard detects task/agentuity_background_task tools - 'Inspect Agent Session' button shows child agent's full conversation Live Sub-Agent Streaming: - SSE proxy forwards all events tagged with _meta session metadata - useSessionEvents reducer handles child events (messages, parts, status) - ChildSessionView renders live streaming with animated Live indicator - Auto-scroll during active streaming Review fixes applied: - Batch inArray() queries replacing N+1 pattern - Optimistic locking for archive race prevention - Foreign key indexes on all archive tables - Graceful degradation for live child session reading - Specific error codes for archive status (503/410/400) - Frontend cache invalidation on archived mode change
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
- Add IF NOT EXISTS guards to all CREATE TABLE, ADD COLUMN, ADD CONSTRAINT, and CREATE INDEX statements across migrations 0002-0007 - Matches pattern established in 0000_init.sql for safe re-runs - Downgrade live child session errors to debug level since sandbox OpenCode SQLite DB is not yet available in production
…ggers Replace one-shot archive-on-delete with event-driven background syncing. Uses sandboxExecute to query OpenCode's SQLite DB inside the sandbox (no file download), parses JSON output, and does full-replace in PostgreSQL archive tables. - Add syncSessionArchive() using sandboxExecute + JSON + PG upsert - Hook into SSE session.idle events for debounced sync (5 min) - Add cron route fallback at /api/cron/archive-sync (every 5 min) - Remove archive attempt from delete endpoint (proactive sync handles it) - Add best-effort sync on termination detection - Add lastArchivedAt column to chatSessions + migration 0008
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
taskandagentuity_background_tasknow show an "Inspect Agent Session" button that expands to reveal the child agent's full conversation inline.Needs this: agentuity/sdk#969
Changes
Backend
src/lib/sqlite/(4 files)src/lib/archive.tssrc/db/schema.ts+ 2 migrationsarchiveStatuscolumnsrc/routes/session-detail.tsGET /:id/archive,GET /:id/archive/children,GET /:id/archive/children/:childId,GET /:id/childrensrc/routes/chat.ts_meta: { sessionId, isParent }src/routes/session-detail.tsFrontend
ArchivedBanner.tsx,ChatPage.tsxChildSessionView.tsx,ToolCallCard.tsxuseChildSessions.ts,useSessionEvents.tsAppContext.tsxarchiveStatusto Session typeReview Fixes Applied
inArray()queriesWHERE archiveStatus='none')Testing
bunx tsc --noEmit✅ zero errorsdrizzle-kit pushordrizzle-kit migrateto apply schema changes